clear all

// SET MACROS
global Input  "Y:/limited/Michigan_CTE/funding_change/data_final"
global Output "Y:/limited/Michigan_CTE/funding_change/output/figures"

qui include "Y:/limited/Michigan_CTE/funding_change/code/analyze/figures/00_colors.do"

local demographics "female black hisp another_race sped lep econdis"
local academics "test_avg_g8 test_avg_sq_g8 test_avg_g8_imp attendance_g8 attendance_g8_imp"

// LOAD DATA
use $Input/compiled_student_analysis_data.dta


keep if grad_year >= 2012
replace c2014 = 0

foreach x in cte_any cte_conc_comp cte_comp {
	replace 	`x' = `x'*100
}

eststo: reghdfe cte_any c2012-c2019 `demographics' `academics', a(school) vce(cluster school)

eststo: reghdfe cte_conc_comp c2012-c2019 `demographics' `academics', a(school) vce(cluster school)

eststo: reghdfe cte_comp c2012-c2019 `demographics' `academics', a(school) vce(cluster school)

forvalues y = 0/1 {
 eststo: reghdfe cte_comp c2012-c2019 `demographics' `academics' if district_most_poor == `y', a(district) cluster(district)
}

forvalues y = 1/4 {
  eststo: reghdfe cte_comp c2012-c2019 `demographics' `academics' if district_urbanicity == `y' , a(district) cluster(district)
}


// LOAD DATA
use $Input/dcode_funding.dta, clear

keep if inrange(year,2012, 2019)

foreach v in cte_funds_state60 cte_funds_cepd40 cte_funds_total {
	gen all_`v'_n = dcode_`v' + isd_`v'_n
}

foreach v of varlist all_cte_funds_* {
	gen ps_`v' = `v' / hs_students
}

forval i = 2012/2019 {
	gen c`i' = year == `i' 
}
replace c2014 = 0


foreach n in 0 1 {
	eststo: reghdfe ps_all_cte_funds_total c2012-c2019 if district_most_poor == `n' [aw=hs_students], a(dcode) cluster(dcode)
}

forvalues n = 1/4 {
	eststo: reghdfe ps_all_cte_funds_total c2012-c2019 if district_urbanicity == `n' [aw=hs_students], a(dcode) cluster(dcode)
}


estout using Y:/limited/Michigan_CTE/funding_change/output/tab02_all_reg.txt,  keep(c2*) ///
	  cells(b(star fmt(2)) se(par(( )) fmt(2))) ///
	  stats(N , fmt(0)) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	  delimiter("," ) replace label
		
		
